python基础之使用os.system来执行系统命令 | 您所在的位置:网站首页 › python os的使用 › python基础之使用os.system来执行系统命令 |
今天我们来尝试使用python 的os.system来执行系统命令
可以使用如下方法:
import os print os.system('ping www.ucloud.cn') 输出的结果是:64 bytes from 223.26.58.21: icmp_seq=0 ttl=245 time=36.798 ms 64 bytes from 223.26.58.21: icmp_seq=1 ttl=244 time=37.561 ms 64 bytes from 223.26.58.21: icmp_seq=1 ttl=246 time=37.161 ms 64 bytes from 223.26.58.21: icmp_seq=1 ttl=245 time=35.123 ms 64 bytes from 223.26.58.21: icmp_seq=1 ttl=248 time=37.146 ms 这样就完成了这个简单的功能,就这么简单,两句话,哈哈 但是大部分动作都是由os模块来帮助我们完成了,现成的模块功能非常多,这是python的一大特色 下面我们再来做一个另外的例子:import os print os.system('ifconfig') 执行以下……自己可以去实验以下哈 感兴趣的话,可以用python os.system 来尝试更多的系统命令……还是非常强大的 文章来源:,作者:。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:sean.li#ucloud.cn(邮箱中#请改为@)进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。 后台-系统设置-扩展变量-手机广告位-内容正文底部 |
CopyRight 2018-2019 实验室设备网 版权所有 |